//
//  ActivityViewController.m
//  TheRoadAD
//
//  Created by baixue on 16/8/10.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "ActivityViewController.h"

#import "ActiveView.h"//view

#import "ActivitySearchViewController.h"//搜索Controller
#import "TrackDayViewController.h"//赛道日Controller

@interface ActivityViewController () <UIScrollViewDelegate>

@end

@implementation ActivityViewController

#define ScrollViewHeight (17 + 60 + (Screen_Width - 20 - 16) / 22 * (7 + 15 + 7) + (Screen_Width - 20) / 69 * 28)

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置导航栏
    [self setNav];
    
    //创建ScrollView
    [self setScrollView];
}

- (void)setNav{
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
    self.navigationItem.title = @"活动";
    
    self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blackColor], NSFontAttributeName : [UIFont fontWithName:AppFont size:18]};
    
    UIBarButtonItem *search = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_find"] style:UIBarButtonItemStylePlain target:self action:@selector(searchActivity)];
    self.navigationItem.rightBarButtonItem = search;
}

- (void)setScrollView{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height)];
    //实际尺寸
    scrollView.contentSize = CGSizeMake( Screen_Width, ScrollViewHeight);
//    scrollView.delegate = self;
    scrollView.showsVerticalScrollIndicator = NO;
    [self.view addSubview:scrollView];
    
    
    ActiveView *view = [[[NSBundle mainBundle] loadNibNamed:@"ActiveView" owner:nil options:nil] lastObject];
    view.frame = CGRectMake(0, 0, Screen_Width, ScrollViewHeight);
    view.activityClick = ^(int temp){
        TrackDayViewController *track = [[TrackDayViewController alloc] init];
        switch (temp) {
            case 0://赛道日
                track.temp = 0;
                break;
            case 1://自驾游
                track.temp = 1;
                break;
            case 2://静态展示
                track.temp = 2;
                break;
            case 3://室内聚会
                track.temp = 3;
                break;
            case 4://兜一兜
                track.temp = 4;
                break;
            case 5://越野
                track.temp = 5;
                break;                
            case 6://婚车租赁
                track.temp = 6;
                break;
            default:
                break;
        }
        track.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:track animated:YES];
    };
    [scrollView addSubview:view];
}


- (void)searchActivity{
    ActivitySearchViewController *search = [[ActivitySearchViewController alloc] init];
    search.index = 2;
    search.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:search animated:YES];
}


@end
